Skip to content

docs: standardize API code examples to ESM - #65641

Closed
spjoshis wants to merge 1 commit into
nodejs:mainfrom
spjoshis:fix/issue-65536
Closed

docs: standardize API code examples to ESM#65641
spjoshis wants to merge 1 commit into
nodejs:mainfrom
spjoshis:fix/issue-65536

Conversation

@spjoshis

Copy link
Copy Markdown

Summary

  • Remove dual mjs and cjs code blocks from API documentation
  • Standardize on single ```js blocks with ESM imports as the canonical paradigm
  • Eliminates redundant documentation cruft and significantly reduces file size across doc/api

Why This Change Was Made

The dual ESM/CJS examples in the API docs were repetitive and difficult to maintain. Since converting between ESM and CJS imports for built-in modules is trivial and obvious, maintaining two separate blocks for each example was not a good use of documentation space or reviewer time.

This change follows the proposal in #65536 to canonicalize on ESM imports unless an example is specifically demonstrating CJS-specific behavior.

Test Plan

  • Verified documentation renders correctly with single ESM code blocks
  • Spot-checked multiple files to ensure conversions are accurate
  • All doc/api markdown files updated consistently

Fixes #65536

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/crypto
  • @nodejs/ffi
  • @nodejs/http
  • @nodejs/http2
  • @nodejs/loaders
  • @nodejs/net
  • @nodejs/userland-migrations

@nodejs-github-bot nodejs-github-bot added the doc Issues and PRs related to Node.js documentation. label Aug 29, 2026
- Remove dual mjs/cjs code blocks from API documentation
- Use single ```js blocks with ESM imports as the canonical form
- Eliminates redundant documentation and reduces file size
- Resolves nodejs#65536

Signed-off-by: Gopal <gopal.joshi73@hotmail.com>
@MikeMcC399

Copy link
Copy Markdown
Contributor

@spjoshis

Please read the comment #65536 (comment) from @Renegade334

This is a policy proposal, not a bug.

So it is too early to submit a PR to implement the proposed change. It first needs to be discussed.

@spjoshis spjoshis closed this Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc Issues and PRs related to Node.js documentation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proposal: Remove ESM/CJS duality from code samples in API docs

3 participants